<template>
  <div class="system">
    <el-row class="m-b bg-white search-content">
      <div class="form-box">
        <SearchComp label-width="60px" :searchData="searchData" :searchForm="searchForm" :searchAction="searchHandle" />
      </div>
    </el-row>
    <div v-loading="loading" class="infinite-list-wrapper bg-white" style="overflow:auto">
      <ul class="list" infinite-scroll-disabled="disabled">
        <li v-for="(item, index) in tableData" :key="index" class="list-item">{{ item }}</li>
      </ul>
    </div>
  </div>
</template>

<script>
// import { getSystemLog } from '@/api/log.js'
// import { getSystemDictList } from '@/api/common'
export default {
  name: 'LogSystem',
  data() {
    return {
      total: 50,
      loading: false,
      tableData: [],
      searchForm: {
        changeMethod: () => {
          this.initData();
        },
        formData: [
          {
            type: 'Select',
            label: '类型',
            prop: 'type',
            filterable: true,
            options: [
              {
                label: '运行日志',
                value: 'info'
              },
              {
                label: '错误日志',
                value: 'error'
              }
            ],
            props: { label: 'label', value: 'value' },
            change: () => this.initData(),
            placeholder: '请选择服务'
          }
        ]
      },
      searchHandle: [
        {
          label: '重置',
          handle: () => this.reset()
        }
      ],
      searchData: {}
    }
  },
  computed: {
    noMore() {
      return this.total >= 200
    },
    disabled() {
      return this.loading || this.noMore
    }
  },
  created() {
    this.getLogType()
    this.initData()
  },
  methods: {
    initData() {
      let res = {
        "code": 200,
        "message": "执行成功",
        "data": [
          "2024-04-19 00:00:00 [INFO ] cn.tech.common.config.TaskOne getCron 145 没有任务，暂不执行",
          "2024-04-19 02:00:00 [INFO ] cn.tech.common.config.PollingTask delLog 94 清楚七天前的code为200的查询日志======成功",
          "2024-04-19 02:42:39 [INFO ] org.apache.coyote.http11.Http11Processor log 175 Error parsing HTTP request header",
          " Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.",
          "java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol [RTSP/1.00x0d0x0a0x0d0x0a...]",
          "\tat org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:558)",
          "\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:263)",
          "\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)",
          "\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)",
          "\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)",
          "\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)",
          "\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)",
          "\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)",
          "\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)",
          "\tat java.lang.Thread.run(Thread.java:748)",
          "2024-04-19 09:26:56 [INFO ] org.apache.coyote.http11.Http11Processor log 175 Error parsing HTTP request header",
          " Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.",
          "java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x020x000x010x000x010xfc0x030x030xc70xaeW0xb9+>0x9a0xca:G0xc50xd8m0xd80x7fC0xc00xa90x110xac;t0xdff0x14\"0xa4t0xe40xe20x0dM ]. HTTP method names must be tokens",
          "\tat org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:407)",
          "\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:263)",
          "\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)",
          "\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)",
          "\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)",
          "\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)",
          "\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)",
          "\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)",
          "\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)",
          "\tat java.lang.Thread.run(Thread.java:748)"
        ]
      }
      // this.loading = true
      // if (this.searchData.type === '') {
      //   delete this.searchData.type
      // }
      // getSystemLog(this.searchData).then(res => {
      this.tableData = res.data
      // this.total = res.total;
      // })
      //   .finally(() => {
      //     this.loading = false
      //   })
    },
    reset() {
      this.searchData.type = this.searchForm[0].options[0].sdeValue
      this.initData()
    },
    getLogType() {
      // this.$getList(
      //   getSystemDictList({
      //     systemDictName: 'log_type'
      //   })
      // ).then(res => {
      //   this.searchForm[0].options = res.data
      //   this.searchData.path = res.data[0].sdeValue
      //   this.initData()
      // })
    }
  }
}
</script>

<style>
  .system {
    min-height: 600px;
    max-height: 750px;
    overflow: scroll;
  }
</style>
